// 数据结构的封装 -- 贯穿到整个项目中
import Category from "./CateEnum" // 分类的枚举类型
class ItemData {
  id!: number; // 不加！会报错提示
  cateGoryId!: Category;
  title!: string;
  content!: string;
  createTime!: string;
  // constructor 初始化数值
  constructor(id = -1, cateGoryId:Category = -1, title = '', content = '') {
    this.id = id
    this.cateGoryId = cateGoryId
    this.title = title
    this.content = content
    this.createTime = this.dateFormat()
  }
  dateFormat():string{
    let date = new Date()
    let str = date.getFullYear()+'-'+
    ((date.getMonth()+1).toString().padStart(2, '0'))+'-'+
    (date.getDate())+ '  '+
    ((date.getHours()).toString().padStart(2, '0'))+'：'+
    ((date.getMinutes()).toString().padStart(2, '0'))
    return str
  }
}

export default ItemData;